package No101_200.No121_130.ValidPalindrome_125;

public class Solution {
	public static boolean isPalindrome(String s) {
		s = s.toLowerCase();
		for (int i = 0, j = s.length()-1; i <= j; ) {
			if (i == j) {
				return true;
			}
			char a,b;
			if ((s.charAt(i)>='a' && s.charAt(i)<='z')||(s.charAt(i)>='0' && s.charAt(i)<='9')) {
				a = s.charAt(i);
			}else {
				i++;
				continue;
			}
			if ((s.charAt(j)>='a' && s.charAt(j)<='z')||(s.charAt(j)>='0' && s.charAt(j)<='9')) {
				b = s.charAt(j);
			} else {
				j--;
				continue;
			}
			if (a == b) {
				i++;j--;
			} else {
				return false;
			}
		}
		return true;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		if (isPalindrome("0P")) {
			System.out.println("palindrome");
		}else {
			System.out.println("not");
		}
	}

}
